package com.zhiying.jpa;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.zhiying.domain.CMS_Menu;
import com.zhiying.domain.CMS_Organization;
import com.zhiying.domain.CMS_User;
import com.zhiying.domain.Role;
import com.zhiying.domain.UserLoginLog;
@Transactional
public interface MenuJPA extends JpaRepository<CMS_Menu, Integer>{

	
    @Query("from CMS_Menu where parent_id=1")
	List<CMS_Menu> SelectMenuOneLIst();
	
	@Query("from CMS_Menu where parent_id in (select menu_id from CMS_Menu where parent_id=1)")
	List<CMS_Menu> SelectMenusubmenuList();
	
	
	
	@Query(value="select lo.user_id,lo.create_time,lo.spend_time,us.update_by from cms_log as lo,cms_user as us where lo.user_id=us.user_id and lo.log_id=32",nativeQuery=true)
	CMS_User selectRole();
	
	@Query(value="from Role where status=:status")
	List<Role> selectRoleList(@Param("status")Integer status);
    
	@Query("from CMS_Organization where status=:status")
	List<CMS_Organization>  listBySataus(@Param("status")Integer status);
	
	@Query("from CMS_User user,CMS_Organization org where org.organizationId=user.Organization.organizationId and user.userId=:id")
	CMS_User selectUserById(@Param("id")Long id);
	
	
	@Query(value="select*from cms_role where status=#{status}",nativeQuery=true)
	List<Role> selectRoleAll(@Param("status")int status);

}
